<?php

namespace App\Http\Controllers\Code;
use Session,Config;
use Illuminate\Http\Request;
use App\Http\Service\User\UserService;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class CodeController extends Controller
{
    public function getSmsCode(Request $request)
    {

        $error_ret = [
            'error_code' => -1,
            'error_message' => "错误的验证码",
            ];

        $validateCode = $request->input('validateCode');

        $code = Session::get('VERIFICATION');

        $validateCode = strtolower($validateCode);
        //   检测验证码
        $validateCode = md5($validateCode.'niumokeji888');

        if($code != $validateCode)
        {
            return response()->json($error_ret);
        }

        $where=[];
        $where['mobile']=$request->input('mobile');

        $user = new UserService();
        $data = $user->getCode($where);

        return $data;

    }

    public function getIp()
    {

        $ip = $_SERVER["REMOTE_ADDR"];
        echo $ip;
    }
    
}
